<%@ page language="java" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<title>会议管理</title>
</head>
<style>
.margin_{
 margin: 5px;
}
</style>
<body style="background-color: rgba(187, 179, 179, 0.38);" onload="loadMessageCount()">
<div class="container">
         <jsp:include page="header.jsp"/>
<h1 class="col-sm-12" style="font-family:迷你简菱心;"><strong>会议管理系统</strong></h1>
<br><br><br>
<div class="col-sm-2">
			<div data-spy="affix" data-offset-top="160" data-offset-bottom="0">
				<ul class="nav nav-pills nav-stacked">
					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 我的会议<span class="caret"></span> </a>
						<ul class="dropdown-menu">
							<li><a href="myMeetingInfo.action#future7">未来7天内的会议</a></li>
							<li><a href="myMeetingInfo.action#myOrder">我预约的会议</a></li>
							<li><a href="myMeetingInfo.action#ended">已结束的会议</a></li>
							<li><a href="myMeetingInfo.action#cancel">已取消的会议</a></li>
						</ul>
					</li>

					<li class="dropdown"><a class="dropdown-toggle"
						data-toggle="dropdown" href="#"> 申请会议<span class="caret"></span>
					</a>
						<ul class="dropdown-menu">
							<li><a href="applyByTimeAndNumber.action">通过时间和容量</a>
							</li>
							<li><a href="applyMeetingByAddress.action">通过地点</a>
							</li>
						</ul>
					</li>
					<li><a href="personalInfo.action">
							个人信息</a>
					</li>
					<li><a href="getInvitationInfo.action">
							<span class="badge pull-right" id="mCount"></span>消息</a>
					</li>

				<c:if test="${sessionScope.adminFlag == '1'}">
						<li><a type="button" data-toggle="collapse" data-target="#admin">管理功能</a></li>
						</c:if>
				</ul>
				<div id="admin"  class="collapse in">
					<ul class="nav nav-pills nav-stacked">
						<li><a href="getPersonAction.action">人员管理</a>
						</li>
						<li><a href="GetMeetingRoomAction.action"><span
								class="badge pull-right"></span>会议室管理</a>
						</li>
						<li><a href="getDeviceAction.action"><span
								class="badge pull-right"></span>设备管理</a>
						</li>
						<li><a href="getDepartmentAction.action"><span
								class="badge pull-right"></span>部门管理</a>
						</li>
						<li  class="active"><a href="GetMeetingAction.action"><span
								class="badge pull-right"></span>会议管理</a>
						</li>
					</ul>
				</div>
				<!-- 管理界面 -->


			</div>
			<!--  -->
		</div>
  <div class="col-sm-10">
  <ol class="breadcrumb">
  <li><a href="myMeetingInfo.action">主页</a></li>
  <li class="active">会议管理</li>
</ol>

<div class="panel panel-info">
  <div class="panel-heading col-sm-12">
     <h3 class="panel-title col-sm-4"  style="margin-top: 10px;padding-left: 0px;">会议信息</h3>
    <div class="col-sm-8 pull-right">
    					<form action="SearchMeetingAction" method="post">
						<div class="input-group col-sm-6 pull-right">
							<input id="searchMes" name="searchMes" type="text" class="form-control " placeholder="请输入会议主题">
							<div class="input-group-btn">
								<button type="submit" class="btn btn-default">
									<span class="glyphicon glyphicon-search"></span> 搜索
								</button>
							</div>
							<!-- /btn-group -->
						</div>
						</form>
						
						
						<!-- /input-group -->
					</div>
    
  </div>
  <table class="table table-striped table-bordered" >

 <tr align="center">
 <td>会议主题</td>
 <td>开始时间</td>
 <td>结束时间</td>
 <td>状态</td>
 <td>操作</td>
 </tr>
 
 <c:forEach items="${meetingMes}" var="meMes">
 <tr align="center" id="${meMes.topic}">
 <td>${meMes.topic}</td>
 <td>${meMes.startTime}</td>
 <td>${meMes.endTime}</td>
 <td class="hide">${meMes.content}</td>
 <td class="hide">${meMes.meetingRoom.mrName}</td>
 <td class="hide">
 <c:forEach items="${invitation}" var="inv">
 <c:if test="${inv.meeting.topic==meMes.topic}">
 <span class="label label-info">${inv.staff.SName}</span>
 </c:if>
 </c:forEach>

 </td>
 <td><c:if test="${meMes.state==0}"><span class="label label-info">未开始</span></c:if>
 <c:if test="${meMes.state==1}"><span class="label label-warning">已取消</span></c:if>
 <c:if test="${meMes.state==2}"><span class="label label-default">已结束</span></c:if>
 </td>
 <td><button type="button" class="btn btn-xs btn-default" data-toggle="modal" data-target="#detail" onclick="getDeTopic('${meMes.topic}')">查看详情</button>
<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#confirmModal" onclick="getTopic('${meMes.topic}')">删除</button>
 </td>
 </tr>
 </c:forEach>
</table>
<div align="center">
<ul class="pager">
					<c:if test="${startPage!=null}">
					<c:choose>
					<c:when test="${startPage-1<0}">
					<li class="disabled"><a href="#">上一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="GetMeetingAction.action?startPage=${startPage-1}">上一页</a></li>
					</c:otherwise>
					</c:choose>
					<c:choose>
					<c:when test="${(startPage+1)*6>account}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:when test="${account<=6}">
					<li  class="disabled"><a href="#">下一页</a></li>
					</c:when>
					<c:otherwise>
					<li><a href="GetMeetingAction.action?startPage=${startPage+1}">下一页</a></li>
					</c:otherwise>
					</c:choose>
					</c:if>
</ul>
</div>
</div>
</div>
</div>
<div class="modal fade" id="confirmModal">
		<div class="modal-dialog">
			<div class="modal-content">
			<form action="DeleteMeetingAction" method="post">
				<div class="modal-body">
					<h4>你确定要删除该会议吗？</h4>
				</div>
				<input type="text" class="hide" id="meTopic" name="meTopic">
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					<button type="submit" class="btn btn-danger">确定</button>
				</div>
				</form>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	
	<div class="modal fade" id="detail">
		<div class="modal-dialog">
			<div class="modal-content" >
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">会议详情</h4>
				</div>
				<div class="modal-body">
 				<table class="table table-hover">
 				<tr  class="warning">
 				<td><strong>主题</strong></td>
 				<td id="theme" name="theme">总结大会</td>
 				</tr>
 				
 				<tr  class="warning">
 				<td><strong>地点</strong></td>
 				<td id="address">华南农业大学</td>
 				</tr>
 				
 				<tr  class="warning">
 				<td><strong>开始时间</strong></td>
 				<td id="startTime">2011-12-12</td>
 				</tr>
 				
 				<tr  class="warning">
 				<td><strong>结束时间</strong></td>
 				<td id="endTime">2011-12-12</td>
 				</tr>
 				
 				<tr  class="warning">
 				<td><strong>主要内容</strong></td>
 				<td id="mainContent"><div style="overflow:auto;width: 400px">2011-12-12</div></td>
 				</tr>
 				
				<tr  class="warning">
 				<td><strong>邀请人员</strong></td>
 				<td id="invita"> <div style="overflow:auto">haha</div></td>
 				</tr>	
					 				
 				<tr  class="warning">
 				<td><strong>会议记录</strong></td>
 				<td><a id="detailA" class="alert-link">查看</a></td>
 				</tr>
 				
 				<tr  class="warning">
 				<td><strong>状态</strong></td>
 				<td id="meState"><span class="label label-info">未开始</span></td>
 				</tr>
 				</table>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary">确定</button>
				</div>
				 
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->

</body>
<script src="js/jquery-2.0.1.min.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript">

	function getTopic(topic){
	var meTopic = document.getElementById("meTopic");
	meTopic.value = topic;
}
	
	function getDeTopic(detopic){
		var tr = document.getElementById(detopic);
		var theme = document.getElementById("theme");
		var startTime = document.getElementById("startTime");
		var endTime = document.getElementById("endTime");
		var mainContent = document.getElementById("mainContent");
		var invita = document.getElementById("invita");
		var meState = document.getElementById("meState");
		var address = document.getElementById("address");
		var detailA = document.getElementById("detailA");
		theme.innerHTML = tr.cells[0].innerHTML;
		startTime.innerHTML = tr.cells[1].innerHTML;
		endTime.innerHTML = tr.cells[2].innerHTML;
		mainContent.innerHTML = tr.cells[3].innerHTML;
		address.innerHTML = tr.cells[4].innerHTML;
		invita.innerHTML = tr.cells[5].innerHTML;
		meState.innerHTML = tr.cells[6].innerHTML;
		detailA.href="GetMinStringAction?topic="+encodeURI(encodeURI(detopic));
	}
	
	function loadMessageCount(){
		loadMessageCount_request = false;
		var url="getNewMessage.do";
		if(window.XMLHttpRequest){
			loadMessageCount_request = new XMLHttpRequest();
		}
		else if(window.ActiveXObject){
			try{
				loadMessageCount_request=new ActiveXObject("Msxm12.XMLHTTP");
			}catch (e){
				try{
					loadMessageCount_request=new ActiveXObject("Microsoft.XMLHTTP");
				}catch (e){}
			}
		}
		if(!loadMessageCount_request){
			alert("不能创建X对象");
			return false;
		}
		loadMessageCount_request.onreadystatechange = function(){
			loadMes();
		};
		loadMessageCount_request.open('GET', url, true);
		loadMessageCount_request.send(null);
	}
	
	function loadMes(){
		if(loadMessageCount_request.readyState==4){
			if(loadMessageCount_request.status==200){
				var arr = loadMessageCount_request.responseText;
				var jsonss  =eval("("+arr+")");
				var mCount=document.getElementById("mCount");
				if(jsonss[0]!=0) mCount.innerHTML=jsonss[0];
				}//200
				
				}//4
			
	}//function
</script>
</html>